    #!/bin/bash
    applicationId=`cat /home/Hackplayers/AID $1`
    secretkey=`cat /home/Hackplayers/Sk $1`
    
    LATCH="/home/Hackplayers/latch.accounts"
    account=`grep "^$USER:" $LATCH |cut -d: -f2`
    if [ -z `echo "$account"|cut -d: -f2` ]; then exit 0; fi
    URL="/api/0.6/status/$account"
    requestSignature+="GET\n"
    date=`date -u '+%Y-%m-%d %H:%M:%S'`
    requestSignature+="$date\n\n$URL"
    signed=`echo -en "$requestSignature" | openssl dgst -sha1 -hmac "$secretkey" -binary|sed -e 's|.*= \(.*\)|\1|g'`
    b64signed=`echo -n "$signed"|base64`
    auth_header="Authorization: 11PATHS $applicationId $b64signed"
    date_header="X-11Paths-Date: $date"
    JSON=`wget -q --no-check-certificate -O - --header "$auth_header" --header "$date_header" "https://latch.elevenpaths.com$URL"`
    status=`echo -e "$JSON" | sed -e 's|.*status":"\(.*\)","name.*|\1|g'`
echo -e "$JSON" | sed -e 's|.*status":"\(.*\)","name.*|\1|g' 
   if [ "$status" == "off" ]; then
    echo -e "dispositivo apagado por LATCH\n"
    minicom -D  /dev/rfcomm1 --script /home/Hackplayers/off.sh
    sleep 2
    pkill minicom
    elif [ "$status" == "on" ]; then
    minicom -D  /dev/rfcomm1 --script /home/Hackplayers/on.sh
    sleep 2
    pkill minicom
exit 0
    else
    echo -e "Error de LATCH. Intenta de nuevo\n"
    #pkill ssh
    fi
